package com.core.zyyz.pcmc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.core.zyyz.pcmc.domain.PcmcMsgRecord;
import com.core.zyyz.pcmc.service.PcmcMsgRecordService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.core.common.annotation.Log;
import com.core.common.core.controller.BaseController;
import com.core.common.core.domain.AjaxResult;
import com.core.common.enums.BusinessType;
import com.core.common.utils.poi.ExcelUtil;
import com.core.common.core.page.TableDataInfo;

/**
 * 消息记录Controller
 *
 * @author core
 * @date 2024-10-30
 */
@RestController
@RequestMapping("/pcmc/msgRecord")
public class PcmcMsgRecordController extends BaseController
{
    @Autowired
    private PcmcMsgRecordService pcmcMsgRecordService;

    /**
     * 查询消息记录列表
     */
    @PreAuthorize("@ss.hasPermi('pcmc:msgRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(PcmcMsgRecord pcmcMsgRecord)
    {
        startPage();
        List<PcmcMsgRecord> list = pcmcMsgRecordService.selectPcmcMsgRecordList(pcmcMsgRecord);
        return getDataTable(list);
    }

    /**
     * 导出消息记录列表
     */
    @PreAuthorize("@ss.hasPermi('pcmc:msgRecord:export')")
    @Log(title = "消息记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PcmcMsgRecord pcmcMsgRecord)
    {
        List<PcmcMsgRecord> list = pcmcMsgRecordService.selectPcmcMsgRecordList(pcmcMsgRecord);
        ExcelUtil<PcmcMsgRecord> util = new ExcelUtil<PcmcMsgRecord>(PcmcMsgRecord.class);
        util.exportExcel(response, list, "消息记录数据");
    }

    /**
     * 获取消息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('pcmc:msgRecord:query')")
    @GetMapping(value = "/{messageId}")
    public AjaxResult getInfo(@PathVariable("messageId") Long messageId)
    {
        return success(pcmcMsgRecordService.selectPcmcMsgRecordByMessageId(messageId));
    }

    /**
     * 新增消息记录
     */
    @PreAuthorize("@ss.hasPermi('pcmc:msgRecord:add')")
    @Log(title = "消息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcmcMsgRecord pcmcMsgRecord)
    {
        return toAjax(pcmcMsgRecordService.insertPcmcMsgRecord(pcmcMsgRecord));
    }

    /**
     * 修改消息记录
     */
    @PreAuthorize("@ss.hasPermi('pcmc:msgRecord:edit')")
    @Log(title = "消息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcmcMsgRecord pcmcMsgRecord)
    {
        return toAjax(pcmcMsgRecordService.updatePcmcMsgRecord(pcmcMsgRecord));
    }

    /**
     * 删除消息记录
     */
    @PreAuthorize("@ss.hasPermi('pcmc:msgRecord:remove')")
    @Log(title = "消息记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{messageIds}")
    public AjaxResult remove(@PathVariable Long[] messageIds)
    {
        return toAjax(pcmcMsgRecordService.deletePcmcMsgRecordByMessageIds(messageIds));
    }
}
